﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace yichu_front
{
    public partial class Form_Register : Form
    {
        Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        public Form_Register()
        {
            InitializeComponent();
        }

        private void btn_submit_Click(object sender, EventArgs e)
        {
            string mac = Pub.GetMacAddressByNetworkInformation();
            string macGTP = Pub.GetMacAddressGPT();
            //MD5 MAC地址
            string MD5MAC = Util.MySecurity.GetMD5(mac.Trim() + "!#%&1357QETU");
            string MD5MACGTP = Util.MySecurity.GetMD5(macGTP + "!#%&1357QETU");


            if (SqlSugarHelp.scope.Queryable<Author>().Where(it => it.MAC == mac && it.MD5MAC == MD5MAC).Any())
            {
                cfa.AppSettings.Settings["mac"].Value = mac;
                cfa.Save();
                Form_Login form_Login = new Form_Login();
                form_Login.Show();
                this.Hide();
            }
            else if (SqlSugarHelp.scope.Queryable<Author>().Where(it => it.MAC == macGTP && it.MD5MAC == MD5MACGTP).Any())
            {
                cfa.AppSettings.Settings["mac"].Value = macGTP;
                cfa.Save();
                Form_Login form_Login = new Form_Login();
                form_Login.Show();
                this.Hide();
            }
        }

        private void Form_Register_Load(object sender, EventArgs e)
        {
            this.txt_mac.Text = Pub.GetMacAddressByNetworkInformation();
        }

        private void buttonGPTmac_Click(object sender, EventArgs e)
        {
            this.txt_mac.Text = Pub.GetMacAddressGPT();
        }
    }
}
